﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RawInput;
using MySql.Data.MySqlClient;

namespace TMS
{
    public partial class UserScreen : Form
    {
        //InputDevice BarReader;   

        public int dolzina;
        public Users ActiveUser;

        public UserScreen()
        {
            InitializeComponent();
            
        }

        public UserScreen(Users ActiveUserLogedin)
        {
            InitializeComponent();
            this.ActiveUser = ActiveUserLogedin;
        }

 
        private void m_KeyPressed(object sender, InputDevice.KeyControlEventArgs e)
        {
            //Replace() is just a cosmetic fix to stop ampersands turning into underlines
            //lbHandle.Text = e.Keyboard.deviceHandle.ToString();
            //lbType.Text = e.Keyboard.deviceType;
            //lbName.Text = e.Keyboard.deviceName.Replace("&", "&&");
            //lbDescription.Text = e.Keyboard.Name;
            textBox1.Text = e.Keyboard.key.ToString();
            //lbNumKeyboards.Text = NumberOfKeyboards.ToString();
            //lbVKey.Text = e.Keyboard.vKey;
        }

        //private void textBox1_TextChanged(object sender, EventArgs e)
        //{
           
        //    dolzina = textBox1.Text.Length;
        //    if (true) 
        //    {
        //        MessageBox.Show(dolzina.ToString());
        //    }
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            dolzina = textBox1.Text.Length;
            MessageBox.Show(dolzina.ToString());
        }

        private void KorisnickiForm_Load(object sender, EventArgs e)
        {
            if (ActiveUser.GetLevel() == 1)
            {
                EditUsersScreenLabel.Visible = true;
                ProductLabel.Visible = true;
            }

            if (ActiveUser.GetLevel() == 2)
            {
                ProductLabel.Visible = true;
            }

            ActiveUserInfo.Text = "Активен корисник:" + ActiveUser.GetName() + " " + ActiveUser.GetSurname();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void AddUsersLabel_Click(object sender, EventArgs e)
        {
            //UsersPanel.Visible = true;
            EditUsersScreen frm = new EditUsersScreen(ActiveUser);
            frm.ShowDialog();
        }

        private void ProductLabel_Click(object sender, EventArgs e)
        {
            Products frm = new Products();
            frm.ShowDialog();
        }

        private void btnUsersList_Click(object sender, EventArgs e)
        {
            EditUsersScreen frm = new EditUsersScreen(ActiveUser);
            frm.ShowDialog();
        }

        private void btnProductsList_Click(object sender, EventArgs e)
        {
            Products frm = new Products();
            frm.ShowDialog();
        }
        
    }
}
